package com.kocla.mz.circularanimutil;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.kocla.mz.circularanimutil.utils.CircularAnimUtil;


public class FirstActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);
        final FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_calender);
        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int fromColor = ResourcesCompat.getColor(getResources(), android.R.color.holo_red_dark, null);
                int toColor = getResources().getColor(R.color.violet_dark);
                CircularAnimUtil.startActivity(FirstActivity.this, SecondActivity.class, floatingActionButton,
                        fromColor, toColor, android.R.id.text1);
                //原始写法
//                int[] location = new int[2];
//                floatingActionButton.getLocationInWindow(location);
//                final int cx = location[0] + floatingActionButton.getWidth() / 2;
//                final int cy = location[1] + floatingActionButton.getHeight() / 2;
//                Intent i = new Intent(FirstActivity.this, SecondActivity.class);
//                i.putExtra("x", cx);
//                i.putExtra("y", cy);
//                i.putExtra("fromColor", ResourcesCompat.getColor(getResources(), android.R.color.holo_red_dark, null));
//                startActivity(i);
            }
        });
    }
}
